1. Technical Field
The present invention relates generally to data processing systems and more particularly to data processing systems for creating application programs or operating system programs. Still more particularly, the present invention relates to a callback mechanism for object oriented systems.
2. Description of the Related Art
The development of application and system software for data processing systems has traditionally been a time consuming task. The field of software engineering has attempted to overcome the limitations of traditional techniques by proposing new, more efficient software development models. Object oriented programming has emerged as a promising technology that will allow rapid development, implementation and customization of objects. Each new object has certain data attributes and processes or methods that operate on that data. Data is said to be "encapsulated" by an object and can only be modified by the object methods are invoked by sending a message to an object identifying the method and supplying any needed arguments.
Object oriented systems have two important properties in addition to encapsulation. "Inheritance" is the ability to derive a new object from an existing object and inherit all properties, including methods and data structure, from the existing object. The new object may have certain unique features which are supplied as overrides or modifications to the existing class. For example, a new subclass needs to specify only the functions and data that distinguish that class from the existing more general class.
The ability to override an existing method description enables polymorphism, the ability to have a single message to an object be processed in different ways depending on the object itself.
Inheritance and polymorphism create a powerful structure for implementing new software systems. The software developer does not have to develop each piece of a system, he or she need only specify the unique features of the system.
The power of object oriented systems is realized through the development of system "frameworks." A framework is a collection of base classes that can be used by a system implementor to create a final systems product. The framework is defined and developed to work together as a system. Conceptually, the framework is much like a set of standard hardware components used by computer hardware builders. Each of the components has certain defined functions and interfaces and the engineer assembles these components according to a particular design to create a unique hardware system.
One object oriented programming system is the System Object Model (SOM). More information on SOM can be found in SOMObjects Developer Toolkit User's Guide, version 2.0, June 1993, available from International Business Machines Corporation. More information on object oriented systems and definite terms specific to object oriented systems may be found in Booch, Object Oriented Design With Applications, Benjamin/Cummings Publishing Company, Inc. (1991).
A notification mechanism is a widely used technique in programming to dynamically invoke an operation or procedure that is only available during runtime. Typically, a combination of a hash table and a callback list a are commonly used implement a notification mechanism. A hash table is a table of information that is accessed by way of a shortened search key (a hash value or key). Elements are stored in a table in which each element also includes a unique key. An element is placed in the table by the value returned by the hash function over the unique key. The key may be a string, a pointer address, an integer, or any unique identity. A hash function maps this unique identity to an integer value within the size of the table. Once the element is placed in the keyed position in the table, the element can be retrieved from the array in the same manner that it was placed in the table. A linked list, also called a "chained list", is a list in which the data elements may be disbursed and each data element contains information for locating the next data element. In a linked list, each element has a unique key for retrieval.
The overhead for employing a hash table, however, is typically too high for simple objects. At run time, table look up also introduces performance degradation. In addition, when notifications are introduced by a number of super classes in a multiple, inheritance object oriented environment, the management of notification in the hash table can become extremely complicated. A hash table also is larger than a linked list containing the same amount of elements to avoid key collision. The hash function must be well designed to avoid collision between the hashed key. A collision results in employing a linked list to store the collided elements sharing the same position. A linked list reduces the speed of retrieval of elements when the list size grows. This degradation is caused by the fact that elements on the list must be traversed one by one in order to find the target or desired element.
A callback mechanism is used in notification in procedural programming to allow an existing software module to call subroutines that are only available during run time. The invocation of the run time subroutine is called a "callback". The subroutine is called a "callback procedure". The existing software module learns of the existence of a callback procedure through a registration routine, which requires the name of the invocation and the address of the callback procedure. The registration information is typically placed into a hash table so that the address of the callback procedure can be quickly retrieved by using the name of the invocation as a hash key. The name, however, is usually a text string and time is required to convert a text string, into a hash key.
As a result, the invocation of a callback procedure with the existing software module is slower than a direct subroutine invocation. In addition, when the number of callback names grows, it becomes hard to manage the names logically. Consequently, it becomes harder and harder for a programmer to employ a callback mechanism. Therefore, it would be advantageous to have an improved callback mechanism that is fast and easy to manage.